<html>
<head><meta charset="utf-8"><title>Is `core` part of the compiler? · wg-secure-code · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/index.html">wg-secure-code</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html">Is `core` part of the compiler?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226736290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226736290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226736290">(Feb 17 2021 at 22:15)</a>:</h4>
<p>I just think that alternate stdlib implementations are an interesting thing, like alternate rust frontends. It seems like it would be easier to specify what no_core rust does than the whole standard library for the purpose of defining "the rust language", but I can kind of see the point that <code>#[no_core]</code> should be unstable because maybe it is unpredictable what happens if you don't get the intrinsic definitions right or something</p>



<a name="226736432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226736432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226736432">(Feb 17 2021 at 22:16)</a>:</h4>
<p>I don't think core should be considered separate from the compiler, really. There's no clear boundary between the two like there is between the frontend and codegen</p>



<a name="226736532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226736532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226736532">(Feb 17 2021 at 22:17)</a>:</h4>
<p><a href="https://github.com/japaric/steed">https://github.com/japaric/steed</a> is an alternative stdlib of sorts</p>



<a name="226736696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226736696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226736696">(Feb 17 2021 at 22:19)</a>:</h4>
<p>that only overrides std, not core: <a href="https://raw.githubusercontent.com/japaric/steed/master/Xargo.std.toml">https://raw.githubusercontent.com/japaric/steed/master/Xargo.std.toml</a></p>



<a name="226737345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737345">(Feb 17 2021 at 22:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/146229-wg-secure-code/topic/Stack.20smash.20protection/near/226736290">said</a>:</p>
<blockquote>
<p>I just think that alternate stdlib implementations are an interesting thing, like alternate rust frontends. It seems like it would be easier to specify what no_core rust does than the whole standard library for the purpose of defining "the rust language", but I can kind of see the point that <code>#[no_core]</code> should be unstable because maybe it is unpredictable what happens if you don't get the intrinsic definitions right or something</p>
</blockquote>
<p>You can't do that split, though.  <code>for</code> loops are defined in terms of things in <code>core</code>.</p>



<a name="226737397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737397">(Feb 17 2021 at 22:24)</a>:</h4>
<p>Well, that just means that a minimal core library would have to have those particular functions</p>



<a name="226737453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737453">(Feb 17 2021 at 22:25)</a>:</h4>
<p>Perhaps core is already a minimal core library but I kind of doubt it</p>



<a name="226737495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737495">(Feb 17 2021 at 22:25)</a>:</h4>
<p>the smallest program that will compile with rustc is</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="o">&gt;</span><span class="w"> </span><span class="n">cat</span><span class="w"> </span><span class="n">no_core</span><span class="p">.</span><span class="n">rs</span><span class="w"></span>
<span class="cp">#![feature(no_core, lang_items)]</span><span class="w"></span>
<span class="cp">#![no_core]</span><span class="w"></span>
<span class="cp">#![crate_type = </span><span class="s">"lib"</span><span class="cp">]</span><span class="w"></span>

<span class="cp">#[lang = </span><span class="s">"sized"</span><span class="cp">]</span><span class="w"></span>
<span class="k">trait</span><span class="w"> </span><span class="nb">Sized</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>



<a name="226737507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737507">(Feb 17 2021 at 22:25)</a>:</h4>
<p>however you can't do basically anything with it</p>



<a name="226737585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737585">(Feb 17 2021 at 22:26)</a>:</h4>
<p>Yeah, that's why I said that you have to at least declare all the lang items</p>



<a name="226737596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737596">(Feb 17 2021 at 22:26)</a>:</h4>
<p>it's not clear to me just how much more is needed</p>



<a name="226737613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737613">(Feb 17 2021 at 22:26)</a>:</h4>
<p>at a minimum everything declared with <code>#[lang]</code> I would expect</p>



<a name="226737630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737630">(Feb 17 2021 at 22:26)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/enum.LangItem.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/enum.LangItem.html</a></p>



<a name="226737679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737679">(Feb 17 2021 at 22:27)</a>:</h4>
<p>although I think some of those are just to get around coherence so <code>&amp;[T]</code> can have impls in <code>alloc</code></p>



<a name="226737683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737683">(Feb 17 2021 at 22:27)</a>:</h4>
<p>Some impl blocks probably contain more than strictly necessary, for example convenience functions on slices that can't be added any other way</p>



<a name="226737819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737819">(Feb 17 2021 at 22:28)</a>:</h4>
<p>does that lang item list contain functions? It doesn't look like it</p>



<a name="226737844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737844">(Feb 17 2021 at 22:28)</a>:</h4>
<p>it does: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/enum.LangItem.html#variant.Start">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/enum.LangItem.html#variant.Start</a></p>



<a name="226737903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737903">(Feb 17 2021 at 22:29)</a>:</h4>
<p>fun fact, if you have <code>#[lang = "start"] fn main() {}</code> you get an LLVM assertion</p>
<div class="codehilite"><pre><span></span><code>Incorrect number of arguments passed to called function!
  call void @_ZN7no_core4main17hcfbee2d9fb02fb1cE(i8** bitcast (void ()* @_ZN7no_core4main17hc78cb1867f4ab228E to i8**), i64 %3, i8** %1)
SExt only operates on integer
  %4 = sext void &lt;badref&gt; to i32
in function main
LLVM ERROR: Broken function found, compilation aborted!
</code></pre></div>



<a name="226737975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226737975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226737975">(Feb 17 2021 at 22:30)</a>:</h4>
<p>That enum should really have docs btw, that seems like a really good place to collect short blurbs about what lang items exist and why</p>



<a name="226738081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738081">(Feb 17 2021 at 22:30)</a>:</h4>
<p>heh, the closest link I found was <a href="https://doc.rust-lang.org/1.9.0/book/lang-items.html">https://doc.rust-lang.org/1.9.0/book/lang-items.html</a></p>



<a name="226738091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738091">(Feb 17 2021 at 22:30)</a>:</h4>
<p>probably we should move that into the dev guide</p>



<a name="226738159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738159">(Feb 17 2021 at 22:31)</a>:</h4>
<p>at the very least it would be nice to have a link to the name of each of those things in rust</p>



<a name="226738252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738252">(Feb 17 2021 at 22:32)</a>:</h4>
<p>which would make it obvious what's a function and what's a type</p>



<a name="226738260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738260">(Feb 17 2021 at 22:32)</a>:</h4>
<p>I'd take a PR for that :)</p>



<a name="226738304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738304">(Feb 17 2021 at 22:32)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="226738331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738331">(Feb 17 2021 at 22:32)</a>:</h4>
<p>also it does distinguish the two in teh source: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/lang_items.rs.html#265">https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_hir/lang_items.rs.html#265</a></p>



<a name="226738421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738421">(Feb 17 2021 at 22:33)</a>:</h4>
<p>oh nice, so the docs can even be autogenerated to some extent</p>



<a name="226738423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738423">(Feb 17 2021 at 22:33)</a>:</h4>
<p>maybe that macro could autogenerate some docs based on that</p>



<a name="226738539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738539">(Feb 17 2021 at 22:34)</a>:</h4>
<p>and there's a small snippet on the module too: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/index.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/index.html</a></p>



<a name="226738600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738600">(Feb 17 2021 at 22:35)</a>:</h4>
<p>but yeah in general rustc is really bad at internal documention lol</p>



<a name="226738660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226738660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226738660">(Feb 17 2021 at 22:35)</a>:</h4>
<p>I have yet to see a convincing reason why anyone not working on the compiler should need to care about the list.  <code>no_core</code> is not a real scenario.  Something like <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/struct.LanguageItems.html#method.shl_assign_trait">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/lang_items/struct.LanguageItems.html#method.shl_assign_trait</a> -- perhaps with better auto-generated comments -- seems fine.</p>
<p>(And I've seen much unhelpful noise caused by people worrying about whether a particular change adds a lang item.)</p>



<a name="226739089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226739089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226739089">(Feb 17 2021 at 22:38)</a>:</h4>
<p>Although I don't really intend to work on the compiler (I'm getting there...) I am definitely interested in understanding how all the moving parts in rust fit together, and stuff like rustc documentation is super helpful in that regard. I don't think the exact details of the list are all that important but it's good to know the ways in which each of the items does something "magic" that you can't do manually, e.g. <code>RangeToInclusive</code> is on the list because of the <code>..=</code> notation, <code>AddAssign</code> is on the list because it powers the <code>+=</code> operator and so on</p>



<a name="226739567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226739567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226739567">(Feb 17 2021 at 22:44)</a>:</h4>
<p>you might also find <a href="https://doc.rust-lang.org/nightly/nightly-rustc/src/rustdoc/clean/types.rs.html#1588-1662">https://doc.rust-lang.org/nightly/nightly-rustc/src/rustdoc/clean/types.rs.html#1588-1662</a> interesting, it maps types to impls</p>



<a name="226740007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226740007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226740007">(Feb 17 2021 at 22:49)</a>:</h4>
<p>Oh, I found something interesting: <br>
<a href="https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_cranelift/example/mini_core.rs">https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_cranelift/example/mini_core.rs</a></p>



<a name="226741856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226741856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226741856">(Feb 17 2021 at 23:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226739089">said</a>:</p>
<blockquote>
<p>I don't think the exact details of the list are all that important but it's good to know the ways in which each of the items does something "magic" that you can't do manually, e.g. <code>RangeToInclusive</code> is on the list because of the <code>..=</code> notation, <code>AddAssign</code> is on the list because it powers the <code>+=</code> operator and so on</p>
</blockquote>
<p>Note that it's only recently that the lang item list became that -- for quite a while things like <code>?</code> just referenced hard-coded paths.</p>
<p>In general the reference is the right place to understand all those things.  (Or, more accessibly, things like <a href="https://doc.rust-lang.org/nightly/std/#keywords">https://doc.rust-lang.org/nightly/std/#keywords</a> or the fact that you can search for <code>..=</code> <a href="https://doc.rust-lang.org/nightly/std/?search=..%3D">https://doc.rust-lang.org/nightly/std/?search=..%3D</a> )</p>



<a name="226744156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226744156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226744156">(Feb 17 2021 at 23:32)</a>:</h4>
<p>I don't think that any of those methods is complete though</p>



<a name="226744193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226744193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226744193">(Feb 17 2021 at 23:33)</a>:</h4>
<p>well, <code>#keywords</code> is complete for keywords but that's not the same as lang items</p>



<a name="226744285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226744285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226744285">(Feb 17 2021 at 23:34)</a>:</h4>
<p>the advantage of the lang item list is that it is centralized. It's certainly a big improvement over the previous state of affairs that you describe, but it could be better</p>



<a name="226744529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226744529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226744529">(Feb 17 2021 at 23:37)</a>:</h4>
<p>The keyword list looks like just the kind of docs I'm imagining, although the consumers of the lang item documentation would be rustc devs, so it makes more sense as a part of the rustc docs</p>



<a name="226744793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226744793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226744793">(Feb 17 2021 at 23:40)</a>:</h4>
<p>It's a little tricky to find out what the <code>F32Runtime</code> lang item is for that way</p>



<a name="226764166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226764166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226764166">(Feb 18 2021 at 04:41)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F/near/226738260">said</a>:</p>
<blockquote>
<p>I'd take a PR for that :)</p>
</blockquote>
<p>Working on that!</p>



<a name="226834312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226834312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226834312">(Feb 18 2021 at 16:07)</a>:</h4>
<p>if you want a minimal Rust-like language/Rust subset with no <code>core</code> (and formally defined semantics), there's hacspec <a href="https://github.com/hacspec/hacspec">https://github.com/hacspec/hacspec</a></p>



<a name="226835538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226835538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226835538">(Feb 18 2021 at 16:14)</a>:</h4>
<p><span class="user-mention" data-user-id="132721">@Tony Arcieri</span> I took a look, but I'm having trouble finding examples of what the language actually looks like. There's no examples in the readme and the links are broken: <a href="https://github.com/hacspec/hacspec/blob/master/examples/hacspec-chacha20/src/chacha20.rs">https://github.com/hacspec/hacspec/blob/master/examples/hacspec-chacha20/src/chacha20.rs</a></p>



<a name="226835710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226835710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226835710">(Feb 18 2021 at 16:14)</a>:</h4>
<p><a href="https://github.com/hacspec/hacspec/blob/master/examples/chacha20/src/chacha20.rs">https://github.com/hacspec/hacspec/blob/master/examples/chacha20/src/chacha20.rs</a></p>



<a name="226836305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146229-wg-secure-code/topic/Is%20%60core%60%20part%20of%20the%20compiler%3F/near/226836305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tony Arcieri <a href="https://rust-lang.github.io/zulip_archive/stream/146229-wg-secure-code/topic/Is.20.60core.60.20part.20of.20the.20compiler.3F.html#226836305">(Feb 18 2021 at 16:18)</a>:</h4>
<p>it's designed for, among other things, being amenable to symbolic execution environments, e.g. Galois Crucible</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>